package edu.uniquindio.prmaven.proyectofinal;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;

import edu.uniquindio.prmaven.general.TestCore;

public class DataTable_Edit2 extends TestCore{
	
	@Test()
		
		/**
		dataProviderClass = edu.uniquindio.prmaven.dataprovider.DataProviderFactory.class, 
		dataProvider = ConfigurationConstants.DP_FACTORY
		@DataProviderArguments(ConfigurationConstants.ESCENARIO
				+ ConfigurationConstants.EQUALS + DataProvidersConstants.HOJA_1)
				**/
		public void testDataTable_Edit2() throws Exception {
		
		try{
			selenium.open("/showcase/");
			
			//selenium.click("css=#SubMenu-Data > span.MainLinkText"); Seleccion menu Data
			WebElement menu=driver.findElement(By.cssSelector("#SubMenu-Data > span.MainLinkText"));
			menu.click();
			
			//selenium.click("link=• DataTable"); Seleccion Submenu Datatable
			WebElement submenu=driver.findElement(By.xpath("//*[@id='MENUSIDEindent']/div[5]/a[5]"));
			submenu.click();
			
			selenium.waitForPageToLoad("30000");
			
			/*selenium.click("link=• Edit");
			 * xpath .//*[@id='CONTENTSIDEindent']/div[2]/ul/li[12]/a
			 * Seleccion opcion "edit"
			 */
			WebElement edit=driver.findElement(By.xpath
					("//*[@id='CONTENTSIDEindent']/div[2]/ul/li[12]/a"));
			edit.click();
			
			selenium.waitForPageToLoad("30000");
			
			/*selenium.click("//div[@id='form:cars2:3:j_idt121']/div");
			 * Seleccionar registro a modificar
			 */
			WebElement modificarRegistro=driver.findElement(By.xpath
					("//div[@id='form:cars2:3:j_idt121']/div"));
			modificarRegistro.click();
			
			selenium.select("name=form:cars2:3:j_idt123", "label=Renault");
			 
			/*selenium.click("id=j_idt131");
			 * Click para confirmar registro
			 */
			WebElement click=driver.findElement(By.id("j_idt131"));
			click.click();
			
			//Mensaje de confirmacion de edicion registro
			Assert.assertEquals(selenium.getText("css=div.ui-growl-message"), 
					"Cell ChangedOld: Fiat, New:Renault");
			

			selenium.waitForPageToLoad("30000");
			
				
		}catch(AssertionError e){
			System.out.println("no se encontro texto");
		}finally{
			
		}

	}
}



